<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	template="/template/template.xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui">


	<ui:define name="title">Pesquisa de usuários</ui:define>

	<ui:define name="menu">
		<ui:include src="/facelets/user/user_menu.xhtml" />
	</ui:define>

	<ui:define name="content">
		<p:growl id="msgs" />
		<p:panel header="Usuários">
			<p:focus for="username"></p:focus>
			<br />
			<h:panelGrid columns="5" cellpadding="5">
				<label>Apelido: </label>
				<p:inputText id="username" value="#{userMB.username}" title="Apelido do usuário" />
				<label>Nome: </label>
				<p:inputText value="#{userMB.name}" title="Nome do usuário" />
				<p:commandButton action="#{userMB.filter}" ajax="false"
					image="ui-icon ui-icon-search" title="Pesquisar" value="Pesquisar">
				</p:commandButton>
			</h:panelGrid>
			<br />

			<p:dataTable var="user" value="#{userMB.users}" paginator="true"
				widgetvar="minhaTabela" rows="7">
				<p:column>
					<f:facet name="header">
						<h:outputText value="Usuário" />
					</f:facet>
					<h:outputText value="#{user.username}" />
				</p:column>

				<p:column>
					<f:facet name="header">
						<h:outputText value="Nome" />
					</f:facet>
					<h:outputText value="#{user.name}" />
				</p:column>

				<p:column>
					<f:facet name="header">
						<h:outputText value="E-mail" />
					</f:facet>
					<h:outputText value="#{user.email}" />
				</p:column>

				<p:column>
					<f:facet name="header">
						<h:outputText value="Perfil" />
					</f:facet>
					<h:outputText value="#{user.profile.name}" />
				</p:column>

				<p:column style="width:70px" colspan="2">
					<f:facet name="header">
						<h:outputText value="Ações" />
					</f:facet>
					<p:commandButton action="userInsert"
						actionListener="#{userMB.edit}" ajax="false"
						image="ui-icon ui-icon-pencil" title="Editar">
						<f:param id="userEdit" value="#{user}"></f:param>
					</p:commandButton>
					<p:commandButton action="userSearch"
						rendered="#{loginMB.userDeleter}"
						actionListener="#{userMB.delete}" ajax="false"
						image="ui-icon ui-icon-trash" title="Excluir">
						<f:param id="userDelete" value="#{user}"></f:param>
					</p:commandButton>
				</p:column>
			</p:dataTable>

			<h:panelGrid columns="1" cellpadding="5">
				<p:commandButton value="Novo" immediate="true" rendered="#{loginMB.userCreator}"
					image="ui-icon ui-icon-plus" ajax="false" action="userInsert"
					title="Adicionar" />
			</h:panelGrid>
		</p:panel>
	</ui:define>


</ui:composition>